package com.aaa.cs.service.impl;

import com.aaa.cs.dao.MaintainShopDao;
import com.aaa.cs.entity.MaintainShop;
import com.aaa.cs.service.MaintainShopService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MaintainShop)表服务实现类
 *
 * @author makejava
 * @since 2021-01-22 20:44:06
 */
@Service("maintainShopService")
public class MaintainShopServiceImpl implements MaintainShopService {
    @Resource
    private MaintainShopDao maintainShopDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public MaintainShop queryById(Integer id) {
        return this.maintainShopDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<MaintainShop> queryAllByLimit(int offset, int limit) {
        return this.maintainShopDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param maintainShop 实例对象
     * @return 实例对象
     */
    @Override
    public MaintainShop insert(MaintainShop maintainShop) {
        this.maintainShopDao.insert(maintainShop);
        return maintainShop;
    }

    /**
     * 修改数据
     *
     * @param maintainShop 实例对象
     * @return 实例对象
     */
    @Override
    public MaintainShop update(MaintainShop maintainShop) {
        this.maintainShopDao.update(maintainShop);
        return this.queryById(maintainShop.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.maintainShopDao.deleteById(id) > 0;
    }

    /**
     * 通过实体作为筛选条件分页查询
     *
     * @param maintainShop 实例对象
     * @return 对象列表
     */
    @Override
    public PageInfo queryAll(int pageNo, int pageSize, MaintainShop maintainShop) {
        PageHelper.startPage(pageNo, pageSize);
        return new PageInfo<MaintainShop>(this.maintainShopDao.queryAll(maintainShop));
    }
}